﻿//
// Lightbox Gallery Module for DotNetNuke
// Project Contributors - Will Strohl (http://www.WillStrohl.com), Armand Datema (http://www.schwingsoft.com)
//
//Copyright (c) 2009-2013, Will Strohl
//All rights reserved.
//
//Redistribution and use in source and binary forms, with or without modification, are 
//permitted provided that the following conditions are met:
//
//Redistributions of source code must retain the above copyright notice, this list of 
//conditions and the following disclaimer.
//
//Redistributions in binary form must reproduce the above copyright notice, this list 
//of conditions and the following disclaimer in the documentation and/or other 
//materials provided with the distribution.
//
//Neither the name of Will Strohl, Armand Datema, Lightbox Gallery, nor the names of its contributors may be 
//used to endorse or promote products derived from this software without specific prior 
//written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
//EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
//OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
//SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
//TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
//BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
//CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
//DAMAGE.
//

//INSTANT C# NOTE: Formerly VB project-level imports:
using DotNetNuke.Common.Utilities;
using System;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Exceptions;

namespace WillStrohl.Modules.Lightbox
{

	[Serializable()]
	public sealed class SettingInfo : ISettingInfo, IHydratable
	{

#region  Private Members 

		private int p_SettingId = Null.NullInteger;
		private int p_LightboxId = Null.NullInteger;
		private int p_ChangeSpeed = 300;
		private bool p_Cyclic = false;
		private bool p_EnableEscapeButton = true;
		private int p_Margin = 20;
		private bool p_Modal = false;
		private string p_OnCancel = string.Empty;
		private string p_OnCleanup = string.Empty;
		private string p_OnClosed = string.Empty;
		private string p_OnComplete = string.Empty;
		private string p_OnStart = string.Empty;
		private bool p_Opacity = false;
		private string p_OverlayColor = "#666";
		private decimal p_OverlayOpacity = Convert.ToDecimal(0.3);
		private bool p_OverlayShow = true;
		private int p_Padding = 10;
		private bool p_ShowCloseButton = true;
		private bool p_ShowNavArrows = true;
		private int p_Speed = 300;
		private string p_TitlePosition = "over";
		private bool p_TitleShow = true;
		private string p_Transition = "fade";

#endregion

#region  Public Properties 

		public int SettingId
		{
			get
			{
				return p_SettingId;
			}
			set
			{
				p_SettingId = value;
			}
		}

		public int LightboxId
		{
			get
			{
				return p_LightboxId;
			}
			set
			{
				p_LightboxId = value;
			}
		}

		public int ChangeSpeed
		{
			get
			{
				return p_ChangeSpeed;
			}
			set
			{
				p_ChangeSpeed = value;
			}
		}

		public bool Cyclic
		{
			get
			{
				return p_Cyclic;
			}
			set
			{
				p_Cyclic = value;
			}
		}

		public bool EnableEscapeButton
		{
			get
			{
				return p_EnableEscapeButton;
			}
			set
			{
				p_EnableEscapeButton = value;
			}
		}

		public int Margin
		{
			get
			{
				return p_Margin;
			}
			set
			{
				p_Margin = value;
			}
		}

		public bool Modal
		{
			get
			{
				return p_Modal;
			}
			set
			{
				p_Modal = value;
			}
		}

		public string OnCancel
		{
			get
			{
				return p_OnCancel;
			}
			set
			{
				p_OnCancel = value;
			}
		}

		public string OnCleanup
		{
			get
			{
				return p_OnCleanup;
			}
			set
			{
				p_OnCleanup = value;
			}
		}

		public string OnClosed
		{
			get
			{
				return p_OnClosed;
			}
			set
			{
				p_OnClosed = value;
			}
		}

		public string OnComplete
		{
			get
			{
				return p_OnComplete;
			}
			set
			{
				p_OnComplete = value;
			}
		}

		public string OnStart
		{
			get
			{
				return p_OnStart;
			}
			set
			{
				p_OnStart = value;
			}
		}

		public bool Opacity
		{
			get
			{
				return p_Opacity;
			}
			set
			{
				p_Opacity = value;
			}
		}

		public string OverlayColor
		{
			get
			{
				return p_OverlayColor;
			}
			set
			{
				p_OverlayColor = value;
			}
		}

		public decimal OverlayOpacity
		{
			get
			{
				return p_OverlayOpacity;
			}
			set
			{
				p_OverlayOpacity = value;
			}
		}

		public bool OverlayShow
		{
			get
			{
				return p_OverlayShow;
			}
			set
			{
				p_OverlayShow = value;
			}
		}

		public int Padding
		{
			get
			{
				return p_Padding;
			}
			set
			{
				p_Padding = value;
			}
		}

		public bool ShowCloseButton
		{
			get
			{
				return p_ShowCloseButton;
			}
			set
			{
				p_ShowCloseButton = value;
			}
		}

		public bool ShowNavArrows
		{
			get
			{
				return p_ShowNavArrows;
			}
			set
			{
				p_ShowNavArrows = value;
			}
		}

		public int Speed
		{
			get
			{
				return p_Speed;
			}
			set
			{
				p_Speed = value;
			}
		}

		public string TitlePosition
		{
			get
			{
				return p_TitlePosition;
			}
			set
			{
				p_TitlePosition = value;
			}
		}

		public bool TitleShow
		{
			get
			{
				return p_TitleShow;
			}
			set
			{
				p_TitleShow = value;
			}
		}

		public string Transition
		{
			get
			{
				return p_Transition;
			}
			set
			{
				p_Transition = value;
			}
		}

#endregion

		public SettingInfo()
		{
			// do nothing
		}

#region  IHydratable Implementation 

		public int KeyID
		{
			get
			{
				return p_SettingId;
			}
			set
			{
				p_SettingId = value;
			}
		}

		public void Fill(System.Data.IDataReader dr)
		{
			try
			{
				while (dr.Read())
				{
					if (dr[SettingInfoMembers.SettingIdField] != null)
					{
						p_SettingId = int.Parse(dr[SettingInfoMembers.SettingIdField].ToString(), System.Globalization.NumberStyles.Integer);
					}
					if (dr[SettingInfoMembers.LightboxIdField] != null)
					{
						p_LightboxId = int.Parse(dr[SettingInfoMembers.LightboxIdField].ToString(), System.Globalization.NumberStyles.Integer);
					}
					if (dr[SettingInfoMembers.PaddingField] != null)
					{
						p_Padding = int.Parse(dr[SettingInfoMembers.PaddingField].ToString(), System.Globalization.NumberStyles.Integer);
					}
					if (dr[SettingInfoMembers.MarginField] != null)
					{
						p_Margin = int.Parse(dr[SettingInfoMembers.MarginField].ToString(), System.Globalization.NumberStyles.Integer);
					}
					if (dr[SettingInfoMembers.OpacityField] != null)
					{
						p_Opacity = bool.Parse(dr[SettingInfoMembers.OpacityField].ToString());
					}
					if (dr[SettingInfoMembers.ModalField] != null)
					{
						p_Modal = bool.Parse(dr[SettingInfoMembers.ModalField].ToString());
					}
					if (dr[SettingInfoMembers.CyclicField] != null)
					{
						p_Cyclic = bool.Parse(dr[SettingInfoMembers.CyclicField].ToString());
					}
					if (dr[SettingInfoMembers.OverlayShowField] != null)
					{
						p_OverlayShow = bool.Parse(dr[SettingInfoMembers.OverlayShowField].ToString());
					}
					if (dr[SettingInfoMembers.OverlayOpacityField] != null)
					{
						p_OverlayOpacity = decimal.Parse(dr[SettingInfoMembers.OverlayOpacityField].ToString(), System.Globalization.NumberStyles.Float);
					}
					if (dr[SettingInfoMembers.OverlayColorField] != null)
					{
						p_OverlayColor = dr[SettingInfoMembers.OverlayColorField].ToString();
					}
					if (dr[SettingInfoMembers.TitleShowField] != null)
					{
						p_TitleShow = bool.Parse(dr[SettingInfoMembers.TitleShowField].ToString());
					}
					if (dr[SettingInfoMembers.TitlePositionField] != null)
					{
						p_TitlePosition = dr[SettingInfoMembers.TitlePositionField].ToString();
					}
					if (dr[SettingInfoMembers.TransitionField] != null)
					{
						p_Transition = dr[SettingInfoMembers.TransitionField].ToString();
					}
					if (dr[SettingInfoMembers.SpeedField] != null)
					{
						p_Speed = int.Parse(dr[SettingInfoMembers.SpeedField].ToString(), System.Globalization.NumberStyles.Integer);
					}
					if (dr[SettingInfoMembers.ChangeSpeedField] != null)
					{
						p_ChangeSpeed = int.Parse(dr[SettingInfoMembers.ChangeSpeedField].ToString(), System.Globalization.NumberStyles.Integer);
					}
					if (dr[SettingInfoMembers.ShowCloseButtonField] != null)
					{
						p_ShowCloseButton = bool.Parse(dr[SettingInfoMembers.ShowCloseButtonField].ToString());
					}
					if (dr[SettingInfoMembers.ShowNavArrowsField] != null)
					{
						p_ShowNavArrows = bool.Parse(dr[SettingInfoMembers.ShowNavArrowsField].ToString());
					}
					if (dr[SettingInfoMembers.EnableEscapeButtonField] != null)
					{
						p_EnableEscapeButton = bool.Parse(dr[SettingInfoMembers.EnableEscapeButtonField].ToString());
					}
					if (dr[SettingInfoMembers.OnStartField] != null)
					{
						p_OnStart = dr[SettingInfoMembers.OnStartField].ToString();
					}
					if (dr[SettingInfoMembers.OnCancelField] != null)
					{
						p_OnCancel = dr[SettingInfoMembers.OnCancelField].ToString();
					}
					if (dr[SettingInfoMembers.OnCompleteField] != null)
					{
						p_OnComplete = dr[SettingInfoMembers.OnCompleteField].ToString();
					}
					if (dr[SettingInfoMembers.OnCleanupField] != null)
					{
						p_OnCleanup = dr[SettingInfoMembers.OnCleanupField].ToString();
					}
					if (dr[SettingInfoMembers.OnClosedField] != null)
					{
						p_OnClosed = dr[SettingInfoMembers.OnClosedField].ToString();
					}
				}
			}
			catch (Exception ex)
			{
				Exceptions.LogException(ex);
			}
			finally
			{
				if (! dr.IsClosed)
				{
					dr.Close();
				}
			}
		}

#endregion

	}

}